package com.shop.product.controller;

import com.shop.common.core.domain.Result;
import com.shop.common.core.web.controller.BaseController;
import com.shop.common.core.web.page.TableDataInfo;
import com.shop.common.log.annotation.Log;
import com.shop.common.log.enums.BusinessType;
import com.shop.common.security.annotation.RequiresPermissions;
import com.shop.product.domain.MallProductBrandInfo;
import com.shop.product.service.MallProductBrandInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;



@RestController
@RequestMapping("/productBrandInfo")
public class MallProductBrandInfoController extends BaseController {
    @Autowired
    private MallProductBrandInfoService mallProductBrandInfoService;

    /**
     * 查询商品品牌列表
     */
    @RequiresPermissions("product:productBrandInfo:list")
    @GetMapping("/list")
    public Result<TableDataInfo> list(MallProductBrandInfo mallProductBrandInfo)
    {
        startPage();
        List<MallProductBrandInfo> list = mallProductBrandInfoService.selectMallProductBrandInfoList(mallProductBrandInfo);
        return getDataTable(list);
    }


    /**
     * 获取商品品牌详细信息
     */
    @RequiresPermissions("product:productBrandInfo:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(mallProductBrandInfoService.selectMallProductBrandInfoById(id));
    }

    /**
     * 新增商品品牌
     * @param mallProductBrandInfo
     * @return
     */
    @RequiresPermissions("product:productBrandInfo:add")
    @Log(title = "商品品牌", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody MallProductBrandInfo mallProductBrandInfo)
    {
        return toAjax(mallProductBrandInfoService.insertMallProductBrandInfo(mallProductBrandInfo));
    }

    /**
     * 修改商品品牌
     */

    @RequiresPermissions("product:productBrandInfo:edit")
    @Log(title = "商品品牌", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody MallProductBrandInfo mallProductBrandInfo)
    {
        return toAjax(mallProductBrandInfoService.updateMallProductBrandInfo(mallProductBrandInfo));
    }
}
